{template 'member', 'header'}
<div id="memberArea">
	{template 'member', 'left'}
	<div class="col-auto">
		<div class="col-1 ">
			<h5 class="title">{L('会员消费')}</h5>
			<div class="content">
				<div class="getsuss" style="display:none">
					提交成功!等待客户确认支付中...
					
				</div>
			<form method="post" action="" id="myform" name="myform">
			<table width="100%" cellspacing="0" class="table_form">
				<tr>
					<th width="100">{L('account_remain')}：</th> 
					<td>	
						<font style="color:#F00; font-size:18px;font-family:Georgia,Arial; font-weight:700">{$memberinfo[amount]}</font>{L('unit_yuan')}
					</td>
				</tr>
				<tr>
					<th width="100">{L('消费金钱')}：</th> 
					<td>	
						<input type="text" class="input-text" name="money" id="money" size="8">
					</td>
				</tr>
				<tr>
					<th width="100">{L('消费描述')}：</th> 
					<td>	
						<input type="text" class="input-text" name="paydes" id="paydes" size="60">
						<select id="iskuan" onchange="chageval();">
							<option value=''>这里可以快速插入</option>
				{pc:get sql="SELECT * FROM phpcms_good WHERE shop_id='$memberinfo[userid]' ORDER BY price DESC" page="$page" return="data"} 
				{loop $data $r}
							<option value='{$r[price]}--|{$r[title]}'>{$r[title]} - {$r[price]}元</option>
				{/loop}
				{/pc}
						</select>
						<script>
							function chageval(){
								var thedata =$('#iskuan').val();
								var  datas = thedata.split("--|");
								$('#money').val(datas[0]);
								$('#paydes').val(datas[01]);
							}
						</script>
					</td>
				</tr>
				<tr>
					<th width="100">{L('会员手机号')}：</th> 
					<td>	
						<input type="text" class="input-text" name="mobile" id="mobile" size="15">
					</td>
				</tr>
				<tr>
					<th width="100"></th> 
					<td>			
						<input type="button" onclick="waitpay();" class="button" name="dosubmit" value="提交">
						<input type="hidden" id="payid" value="">
					</td>
				</tr>
			</table>
			</form>
			
			</div>
			<span class="o1"></span><span class="o2"></span><span class="o3"></span><span class="o4"></span>
		</div>
		<div class="bk10"></div>
<script>
function waitpay(){
	var money = $('#money').val();
	var paydes = $('#paydes').val();
	var mobile = $('#mobile').val();
	$.post("{APP_PATH}index.php?m=member&c=index&a=usemoney",{ money: money,paydes: paydes,mobile: mobile,dosubmit:1,random:Math.random()}, function(data){
		if(data.indexOf("suss")>=0) {
			$('.getsuss').show();
			var gettime="";	
			var payid = data.replace(/suss/,"");
			$('#payid').val(payid);
			window.clearInterval(gettime); 
			gettime=window.setInterval(chat_mes_get,2000); 
		}else{
			alert(data);
		}
	});
}

function chat_mes_get(payid){
	var payid = $('#payid').val();
	$.post("{APP_PATH}index.php?m=member&c=index&a=payque",{ payid: payid,random:Math.random()}, function(data){
			if(data=="1") {
				alert('确认支付成功!');
				window.location.reload();
			}else if(data=="2") {
				alert('会员取消了此交易!');
				window.location.reload();
			}
	});
}



</script>
	</div>
</div>
<div class="clear"></div>
{template 'member', 'footer'}